﻿package core.display {
	
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;
	import flash.events.Event;
	import core.events.BookCaseEvent;
	
	public class BtnTop extends SimpleButton {
		
		
		public function BtnTop() {
			this.addEventListener(Event.ADDED_TO_STAGE,onInit);
			this.addEventListener(Event.REMOVED_FROM_STAGE,onRemove);
		}
		
		private function onInit(e:Event):void {
			this.removeEventListener(Event.ADDED_TO_STAGE,onInit);
			this.addEventListener(MouseEvent.CLICK,onClick);
		}
		
		private function onRemove(e:Event):void {
			this.removeEventListener(MouseEvent.CLICK,onClick);
		}
		
		private function onClick(e:MouseEvent):void {
			this.dispatchEvent(new BookCaseEvent(BookCaseEvent.TOP_CLICKED));
		}
	}
	
}
